<!-- 没有评论的时候 显示输入框 组件 -->
<template>
  <div id="commentInputCard">
    <!-- 回复框区域 -->
    <div class="reply_input_box">
      <input type="test" class="reply_input" v-model.trim="inputReply" placeholder="回复" :style="true?changeReplyInputStyle:''"/>
      <div class="btn_submit" @click="submitInfor">发布</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'commentInputCard',
  components: {
  },
  props: ['aid'],
  data () {
    return {
      inputReply: '',
      changeReplyInputStyle: [{'width': '88%'}, {'background-color': 'white'}, {'border': '1px solid #8590a6'}]
    }
  },
  computed: {
  },
  methods: {
    submitInfor () {
      // 数据判断为空
      if (this.inputReply.length === 0) {
        this.$Message.error('回复不可为空!')
      } else {
        // 写回答的评论
        this.axios.get('/api/insertComment', {
          params: {
            aid: this.aid,
            phone: sessionStorage.getItem('phone'),
            fromid: 0,
            content: this.inputReply,
            state: 0
          }
        })
          .then((response) => {
            if (response.data.code === 200) {
              this.$Message.success('成功!')
              this.inputReply = ''
              this.getNewData()
            } else {
              this.$Message.error('失败!')
            }
          })
          .catch((error) => {
            this.$Notice.error({
              title: '通知',
              desc: '接口，异常！'
            })
            console.info(error)
          })
      }
    },
    getNewData () {
      this.$emit('getNewData', 1)
    }
  }
}
</script>

<style scoped>
  /*@import 'xxx.css';*/
  #commentInputCard{
    padding: 10px 20px 0px 20px;
  }

  .reply_input_box{
    width: 100%;
    height: auto;
    padding-left: 30px;
    display: inline-block;
  }

  .reply_input{
    width: 100%;
    height: 35px;
    outline: none;
    float: left;
    color: #1a1a1a;
    border-radius: 3px;
    background-color: #f6f6f6;
    font-size: 14px;
    font-weight: normal;
    border: 1px solid #ebebeb;
    padding: 0 20px;
    transition-duration: 0.5s;
    -moz-transition-duration: 0.5s; /* Firefox 4 */
    -webkit-transition-duration: 0.5s; /* Safari 和 Chrome */
    -o-transition-duration: 0.5s; /* Opera */
    margin: 0 0 20px 0;
  }

  .btn_submit{
    height: 34px;
    width: auto;
    display: inline-block;
    font-size: 14px;
    color: #fff;
    cursor: pointer;
    float: right;
    border-radius: 3px;
    line-height: 34px;
    padding: 0px 12px;
    background-color: #0084ff;
  }

  .btn_submit:hover{
    background-color: #006dd5;
  }
</style>
